package com.syni.mdd.sjb.community.base.controller;

import com.syni.mdd.sjb.community.base.entity.dto.PageDTO;
import com.syni.mdd.sjb.community.base.service.SjbQywxChatGroupInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

/**
 * @author wangbaitao
 * @version 1.0.0
 * <h>社群管理接口控制类</h>
 * @Date 2021/3/1
 **/
@RestController
@RequestMapping("group")
public class SjbQywxGroupDataController {
    @Autowired
    private SjbQywxChatGroupInfoService sjbQywxChatGroupInfoService;

    /**getMerchantsUserInfo
     * 根据企业id（corpId）进行群聊信息的同步，默认是获取该企业在应用范围内的全量数据
     *
     * @param corpId 企业id
     * @return 同步结果
     */
    @PostMapping("syncData")
    public Map<String, Object> syncData(@RequestParam("corpId") String corpId) {
        return sjbQywxChatGroupInfoService.syncData(corpId);
    }

    /**
     * 社群管理列表查询接口
     *
     * @param pageDTO 查询对象dto
     * @return 查询结果
     */
    @PostMapping("queryDataByParam")
    public Map<String, Object> queryDataByParam(@RequestBody @Valid PageDTO pageDTO) {
        return sjbQywxChatGroupInfoService.queryDataByParam(pageDTO);
    }

    /**
     * 根据chatId进行群聊信息的查询
     *
     * @param chatId 群聊Id
     * @return 查询结果
     */
    @GetMapping("getChatDataById")
    public Map<String, Object> getChatDataById(@RequestParam("chatId") String chatId) {
        return sjbQywxChatGroupInfoService.getChatDataById(chatId);
    }

    /**
     * 根据企业id获取群主信息集合
     *
     * @param corpId 企业id
     * @return 查询结果
     */
    @GetMapping("getOwnerNames")
    public Map<String, Object> getOwnerNames(@RequestParam("corpId") String corpId) {
        return sjbQywxChatGroupInfoService.getOwnerNames(corpId);
    }

}
